//连接数据库进行数据交互
const { logsModel } = require('./models/logsModel');

// 引入时间插件
const moment = require('moment');

// 显示所有登录日志
module.exports.getLogs = async function () {
    const data = await logsModel.find().populate('adminsId');
    // console.log(data)
    return data
}


// 上传日志信息
module.exports.addLogs = async function (admins) {
    const data = await logsModel.create({ username: admins.accounts, adminsId: admins.id, time: moment().format('YYYY-MM-DD HH:mm') });
    console.log(data)
    return data
}



// 删除日志信息
module.exports.delLogs = async function (id) {
    const data = await logsModel.updateOne({ _id: id.id }, { state: '2' });
    console.log(data)
    return data
}
